<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>


<%@ page import="com.conversationboard.model.*" %>
<%@ page import="com.conversationboard.view.*" %>
<%@ page import="com.conversationboard.config.*" %>
<%@ page import="com.conversationboard.controller.confirm.Confirm" %>
<%@ page import="java.util.List"%>
<%@ page import="com.conversationboard.cache.BannedUser"%>
<%@ page import="com.conversationboard.cache.BannedUserCache"%>

<%@page pageEncoding="UTF-8"%>
<%@page contentType="text/html;charset=UTF-8"%>

<%

	User user = User.get(request.getUserPrincipal());

	List<BannedUser> bannedUsers = BannedUserCache.getBannedUsers(user);
	request.setAttribute("bannedUsers", bannedUsers);
	request.setAttribute("user", user);
	
%>

<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
		<title>Administer Banned Users</title>
		<link rel="stylesheet" type="text/css" href="<%=Configuration.getInstance().getRoot()%>/Stylesheets/<%=StyleSheets.getStyleSheetFileName(request.getCookies())%>"/>
	</head>

	<body>
	
		<%= MainMenu.display(request.getUserPrincipal()) %>

		<div class="headingblock">
			<h1>Unban Person or Range</h1>
		</div>

		<div class="mainblock">
			

			<form class="formsection" action='<%=Configuration.getInstance().getRoot()%>/Admin/AdminUnbanRangeControllerServlet' method="post">
	
			 	<%= Confirm.getKey(request.getUserPrincipal().getName()) %>

				<table class="table">
					<tr class="header">
						<td class="cell">Pattern</td>
						<td class="cell">Banned Until</td>
						<td class="cell">Regular Expression</td>
						<td class="cell">Board</td>
						<td class="cell">Display Name</td>
						<c:if test="${user.siteAdmin}">
							<td class="cell">Banned</td>
						</c:if>
						<td class="cell">Unban</td>
					</tr>			
				
					<c:forEach var="bannedUser" items="${bannedUsers}">
						<tr class="row">
							<td class="cell">${bannedUser.pattern}</td>
							<td class="cell">${bannedUser.bannedUntil}</td>
							<td class="cell">
								<c:choose>
									<c:when test="${bannedUser.regularExpression}"><span class="red"><strong>Yes</strong></span></c:when>
									<c:otherwise>No</c:otherwise>
								</c:choose>
							</td>
							<td class="cell">${bannedUser.boardName}</td>
							<td class="cell">${bannedUser.text}</td>
	
							<c:if test="${user.siteAdmin}">
								<td class="cell">${bannedUser.formattedTimestamp} ${bannedUser.relativeTimestamp}</td>
							</c:if>
	
							<td class="cell"><input type="radio" name="id" value="${bannedUser.id}" /></td>
						</tr>
					</c:forEach>
				</table>
	
				<br />	
			 	<input type="submit" value="      Revoke Ban      " />
			</form>
			
		</div>

		<!--<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>-->
		<!--<script type="text/javascript">_uacct = "UA-1148679-1";urchinTracker();</script>--> 

	</body>
	
</html>
